/**
 * 通知公告
 */
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { SysWechatUser, SysWechatUserParam } from './model';

/**
 * 列表
 */
export async function page(params?: SysWechatUserParam) {
  const res = await request.post<ApiResult<PageResult<SysWechatUser>>>(
    '/sysWechatUser/page',
    { params }
  );
  if (res.data.code === 200) {
    return res.data.result;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 新增
 */
export async function add(data: SysWechatUser) {
  const res = await request.post<ApiResult<any>>('/sysWechatUser/add', data);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 更新
 */
export async function update(data: SysWechatUser) {
  const res = await request.post<ApiResult<any>>('/sysWechatUser/update', data);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除
 */
export async function remove(id?: number | string) {
  const res = await request.post<ApiResult<any>>('/sysWechatUser/delete', {
    id
  });
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
